<template>
  <div class="mod-config">
    <el-table
      :data="dataList"
      border
      v-loading="dataListLoading"
      @selection-change="selectionChangeHandle"
      style="width: 100%;"
      size="mini">
      <el-table-column
        prop="billNo"
        header-align="center"
        align="center"
        label="采购单据号">
      </el-table-column>
      <el-table-column
        prop="submitName"
        header-align="center"
        align="center"
        label="采购人">
      </el-table-column>
      <el-table-column
        prop="productionLine"
        header-align="center"
        align="center"
        label="产线">
      </el-table-column>
      <el-table-column
        prop="codeAndCount"
        header-align="center"
        align="center"
        label="工夹具代码及其数量">
      </el-table-column>
      <el-table-column
        prop="submitTime"
        header-align="center"
        align="center"
        label="申请时间">
      </el-table-column>
      <el-table-column
        prop="status"
        header-align="center"
        align="center"
        label="状态">
        <template slot-scope="scope">
          <span v-if="scope.row.status === '0'">初审未通过</span>
          <span v-else-if="scope.row.status === '1'">初审通过</span>
          <span v-else-if="scope.row.status === '2'">终审未通过</span>
          <span v-else>终审通过</span>
        </template>
      </el-table-column>
      <el-table-column
        fixed="right"
        header-align="center"
        align="center"
        width="150"
        label="操作">
        <template slot-scope="scope">
          <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">查看</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="sizeChangeHandle"
      @current-change="currentChangeHandle"
      :current-page="pageIndex"
      :page-sizes="[10, 20, 50, 100]"
      :page-size="pageSize"
      :total="totalPage"
      layout="total, sizes, prev, pager, next, jumper">
    </el-pagination>
  </div>
</template>

<script>

export default {
  name: "purchaseincomesubmit",
  data(){
    return{
      dataList: [],
      pageIndex: 1,
      pageSize: 10,
      totalPage: 0,
      dataListLoading: false,
    }
  },
  activated () {
    this.getDataList()
  },
  methods: {
    // 获取数据列表
    getDataList() {
      this.dataListLoading = true
      this.$http({
        url: `http://localhost:10000/gongjiajumain/purchaseincomesubmit/list?page=${this.pageIndex}&limit=${this.pageSize}`,
        method: 'get'
      }).then(({data}) => {
        if (data && data.code === 0) {
          this.dataList = data.page.list
          this.totalPage = data.page.totalCount
        } else {
          this.dataList = []
          this.totalPage = 0
        }
        this.dataListLoading = false
        console.log(this.dataList)
      })
    },
    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val
      this.pageIndex = 1
      this.getDataList()
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val
      this.getDataList()
    },
    // 多选
    selectionChangeHandle(val) {
      this.dataListSelections = val
    },
    addOrUpdateHandle(id){
      this.$message({
        message: '傻了吧，还没写哦૮꒰ ˶• ༝ •˶꒱ა',
        type: 'success'
      });
    }
  }
}
</script>

<style scoped>

</style>
